<?php

namespace app\company\controller\user_profile\repealArchive;

use app\company\service\user_profile\repealArchive\RepealArchiveService;
use app\company\service\user_profile\userArchive\UserArchiveService;
use app\BaseController;
use app\common\Message;
use think\App;

class RepealArchive extends BaseController
{
    use Message;

    /**
     * @var array|mixed
     */
    private mixed $data;
    private RepealArchiveService $repealArchive;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $data = $this->request->param();
        $data['uid'] = $this->userData['id'];
        $data['role_mode'] = $this->userData['role_mode'];
        $this->repealArchive = new RepealArchiveService($this->app);
        $this->data = $data;
    }

    /**
     * 废除档案库列表
     * @return bool|string
     */
    public function recordList(): bool|string
    {
        try {
            if(!$this->repealArchive->recordList($this->data)) throw new \Exception($this->repealArchive->getMessage());
            return success($this->repealArchive->getResult(),$this->repealArchive->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }

    /**
     * 废除档案库列表所有数据ID
     * @return bool|string
     */
    public function recordListAll(): bool|string
    {
        try {
            if(!$this->repealArchive->recordListAll($this->data)) throw new \Exception($this->repealArchive->getMessage());
            return success($this->repealArchive->getResult(),$this->repealArchive->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }

}